﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.VisualBasic;

namespace CommunityToolkit.Mvvm_Test
{
    public partial class MainViewModel : ObservableObject
    {
        [ObservableProperty]
       // [NotifyPropertyChangedFor(nameof(Caption))]
        private string textBoxText = "";

        [ObservableProperty]
        [NotifyCanExecuteChangedFor(nameof(ButtonClickCommand))]
        private bool isEnabled;

        partial void OnTextBoxTextChanged(string value)
        {
           OnPropertyChanged(nameof(Caption));         
        }
     

        public string Caption =>$"Titel: {TextBoxText}";

        [RelayCommand(CanExecute = nameof(CanButtonClick))]
        private async Task ButtonClickAsync()
        {
            await Task.Delay(1000);
            TextBoxText = "Good";
        }


        public bool CanButtonClick() => IsEnabled;
     
       

    }
}
